<template>
  <div class="search">
    <f-form ref="form" :action="api.bcr" :form-key="this.formItem.cardserverRecordId" >
      <f-form-item label="卡权益id"  name="cardserverId" dataType="${formField.dataType}"   :value="formItem.cardserverId" />
      <f-form-item label="标题 或 服务名称"  name="title" dataType="${formField.dataType}"   :value="formItem.title" />
      <f-form-item label="描述"  name="body" dataType="${formField.dataType}"   :value="formItem.body" />
      <f-form-item label="optType（1增加，2减少）"  name="optType" dataType="${formField.dataType}"   :value="formItem.optType" />
      <f-form-item label="操作数值"  name="numValue" dataType="${formField.dataType}"   :value="formItem.numValue" />
      <f-form-item label="是否扣除（1已扣除，2未扣除）"  name="isDeduct" dataType="number"   :value="formItem.isDeduct" />
      <f-form-item label="操作人Id"  name="optUserId" dataType="${formField.dataType}"   :value="formItem.optUserId" />
      <f-form-item label=""  name="remark" dataType="${formField.dataType}"   :value="formItem.remark" />
      <f-form-item label="权益日志扩展表类型1appointment,2checkrecord,3第三方调用"  name="targetType" dataType="number"   :value="formItem.targetType" />
      <f-form-item label=""  name="targetId" dataType="${formField.dataType}"   :value="formItem.targetId" />
      <f-form-item label="创建日期"  name="createDate" dataType="${formField.dataType}"   :value="formItem.createDate" />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'bcrForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          cardserverRecordId: '',
          cardserverId: '',
          title: '',
          body: '',
          optType: '',
          numValue: '',
          isDeduct: '',
          optUserId: '',
          remark: '',
          targetType: '',
          targetId: '',
          createDate: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.cardserverRecordId) {
          let params={
              cardserverRecordId:data.cardserverRecordId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem=data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
